package com.example.demo.service;

import com.example.demo.entity.PersonRelationship;
import com.example.demo.mapper.PersonRelationshipMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonRelationshipService {

    @Resource
    private PersonRelationshipMapper personRelationshipMapper;

    public void add(PersonRelationship relationship) {
        personRelationshipMapper.insert(relationship);
    }

    public void update(PersonRelationship relationship) {
        personRelationshipMapper.updateById(relationship);
    }

    public void deleteById(Long id) {
        personRelationshipMapper.deleteById(id);
    }

    public PersonRelationship selectById(Long id) {
        return personRelationshipMapper.selectById(id);
    }

    public List<PersonRelationship> selectAll() {
        return personRelationshipMapper.selectAll();
    }

    public List<PersonRelationship> selectByPersonId1(Long personId) {
        return personRelationshipMapper.selectByPersonId1(personId);
    }

    public List<PersonRelationship> selectByPersonId2(Long personId) {
        return personRelationshipMapper.selectByPersonId2(personId);
    }

    public PageInfo<PersonRelationship> selectPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PersonRelationship> list = personRelationshipMapper.selectAll();
        return PageInfo.of(list);
    }
}